package com.jiyun.controller;

import com.jiyun.entity.day08.TrainingDTO;
import com.jiyun.feign.TrainingFeign;
import com.jiyun.vo.ResultResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Title: TrainingController
 * @Author 杜瑞
 * @Date 2023/8/31 16:45
 */
@RestController
@RequestMapping("training")
public class TrainingController {
    @Autowired
    private TrainingFeign trainingFeign;


    @RequestMapping("findAll")
    public ResultResponse findAll(@RequestBody TrainingDTO trainingDTO){
        try {
            ResultResponse all = trainingFeign.findAll1(trainingDTO);
            return ResultResponse.success(all);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultResponse.error();
        }
    }

    @RequestMapping("findByPx")
    public ResultResponse findByPx(Integer pxId){
        try {
            ResultResponse all = trainingFeign.findByPx(pxId);
            return ResultResponse.success(all);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultResponse.error();
        }
    }

    @RequestMapping("findByKc")
    public ResultResponse findByKc(Integer pxId){
        try {
            ResultResponse all = trainingFeign.findByKc(pxId);
            return ResultResponse.success(all);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultResponse.error();
        }
    }

    @RequestMapping("findBySj")
    public ResultResponse findBySj(Integer pxId){
        try {
            ResultResponse all = trainingFeign.findBySj(pxId);
            return ResultResponse.success(all);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultResponse.error();
        }
    }





}
